package com.ruoyi.web.controller.mxerp;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.VMxTiktokShopDetail;
import com.ruoyi.system.service.MxTiktokShopService;
import com.ruoyi.system.service.VMxTiktokShopDetailService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.MxTiktokShop;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * tk商店管理Controller
 *
 * @author yushuaixm
 * @date 2024-08-16
 */
@RestController
@RequestMapping("/mxerp/tkshop")
public class MxTiktokShopController extends BaseController {
    @Autowired
    private MxTiktokShopService mxTiktokShopService;


    @Autowired
    private VMxTiktokShopDetailService vMxTiktokShopDetailService;

    /**
     * 查询tk商店管理列表
     */
    /*@PreAuthorize("@ss.hasPermi('mxerp:tkshop:list')")
    @GetMapping("/list")
    public TableDataInfo list(MxTiktokShop mxTiktokShop) {
        startPage();
        List<MxTiktokShop> list = mxTiktokShopService.selectMxTiktokShopList(mxTiktokShop);
        return getDataTable(list);
    }*/
    @PreAuthorize("@ss.hasPermi('mxerp:tkshop:list')")
    @GetMapping("/list")
    public TableDataInfo list(VMxTiktokShopDetail vMxTiktokShopDetail) {
        startPage();
        List<VMxTiktokShopDetail> list = vMxTiktokShopDetailService.selectVMxTiktokShopDetailList(vMxTiktokShopDetail);
        return getDataTable(list);
    }

    /**
     * 导出tk商店管理列表
     */
    @PreAuthorize("@ss.hasPermi('mxerp:tkshop:export')")
    @Log(title = "tk商店管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MxTiktokShop mxTiktokShop) {
        List<MxTiktokShop> list = mxTiktokShopService.selectMxTiktokShopList(mxTiktokShop);
        ExcelUtil<MxTiktokShop> util = new ExcelUtil<MxTiktokShop>(MxTiktokShop.class);
        util.exportExcel(response, list, "tk商店管理数据");
    }

    /**
     * 获取tk商店管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('mxerp:tkshop:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(mxTiktokShopService.selectMxTiktokShopById(id));
    }

    /**
     * 新增tk商店管理
     */
    @PreAuthorize("@ss.hasPermi('mxerp:tkshop:add')")
    @Log(title = "tk商店管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MxTiktokShop mxTiktokShop) {
        return toAjax(mxTiktokShopService.insertMxTiktokShop(mxTiktokShop));
    }

    /**
     * 修改tk商店管理
     */
    @PreAuthorize("@ss.hasPermi('mxerp:tkshop:edit')")
    @Log(title = "tk商店管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MxTiktokShop mxTiktokShop) {
        return toAjax(mxTiktokShopService.updateMxTiktokShop(mxTiktokShop));
    }

    /**
     * 删除tk商店管理
     */
    @PreAuthorize("@ss.hasPermi('mxerp:tkshop:remove')")
    @Log(title = "tk商店管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(mxTiktokShopService.deleteMxTiktokShopByIds(ids));
    }
}
